<?php
include_once "../header1.php";
?>

<link href="../style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
require_once '../Login/databaseconnection.php';
if(!loggedin())
{
require_once '../index.php';
}
   
   else
   {
 if(isset($_POST['Search']))
	   {
	  $Lab_Id=$_POST['Lab_Id'];
   $School_Id=$_POST['School_Id'];
	  
	   if($Lab_Id=="Select One"||$School_Id=="Select One")
	   {
		   $_SESSION['errorin1']="Please select the Lab id and School id!";
	   
	   }
	   if($Lab_Id!="Select One"||$School_Id!="Select One")
	   {
	   if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Teacher")
{
   $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
  
   if($School_Id==$Own_School_Id)
	{
	$result=mysql_query("SELECT * FROM lab WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
if(mysql_num_rows($result)==0)
   {

	   $_SESSION['errornorow']="Very sorry there is no result or you are not allowed to search this!";
   }
	}
	 else
	   {
	   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
	   }
	 }
	}
	else if($_SESSION['Access_Type']=="Administrator")
{
    $result=mysql_query("SELECT * FROM lab WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
if(mysql_num_rows($result)==0)
   {

	   $_SESSION['errornorow']="Very sorry there is no result,Please check your input and try again!";
   }
   }
   else
	   {
	   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
	   }
   }
	}  
	   
   ?>
<?php
include_once "../header2.php";
?><?php
include_once "topmenu.php";
?>
<div class="left">
  
<div class="articles">
 <form action="#" method="POST">
 <table width="749" border="0" class="tablefontv">
      <tr>
        <td height="18" colspan="7" align="left" scope="row"><?php
		if(isset($_POST['Search']))
{
	if(isset($_SESSION['errorin1']))
	{
		echo $_SESSION['errorin1'];
		unset($_SESSION['errorin1']);
	}
	if(isset($_SESSION['errornorow']))
	{
		echo $_SESSION['errornorow'];
		unset($_SESSION['errornorow']);
	}
}
		?></td>
        <tr>
        <td width="62" rowspan="2" align="left" scope="row" bgcolor="#6AB5FF">Search by</td>
      <td width="78" height="22" align="left" scope="row" bgcolor="#6AB5FF">Lab Id</td>
      <td width="13" align="left" scope="row" bgcolor="#6AB5FF">:-</td>
      <td colspan="2" bgcolor="#999999"><select name="Lab_Id" id="select">
	   <?php
	  
	  if(isset($_POST['Search']))
	  {
	echo '<option value="'.$Lab_Id.'">'.$Lab_Id.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  ?>
        <?php
	  $lab=mysql_query("SELECT DISTINCT(Lab_Id) FROM lab");
	  
  while($row=mysql_fetch_array($lab))
  {
	 $Lab_Id=$row['Lab_Id'];

	  echo '<option value="'.$Lab_Id.'">'.$Lab_Id.'</option>';
  }
	  ?>
      </select></td>
      <td width="39" rowspan="2" bgcolor="#6AB5FF">Other Way:</td>
      <td width="358" rowspan="2" bgcolor="#999999"><input type="text" name="textfield" />
        <input name="SearchOther" align="middle" type="submit" value="Search" /></td>
      </tr>
    <tr>
      <td width="78" height="22" align="left" scope="row" bgcolor="#6AB5FF">School Id</th>
      <td width="13" align="left" scope="row" bgcolor="#6AB5FF">:-</td>
      <td colspan="2" bgcolor="#999999"><select name="School_Id" id="select">
	  <?php
	  
	  if(isset($_POST['Search']))
	  {
	echo '<option value="'.$School_Id.'">'.$School_Id.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  ?>
        <?php
		
	  $lab=mysql_query("SELECT DISTINCT(School_Id) FROM lab");
	  
  while($row=mysql_fetch_array($lab))
  {
	  $Sch_Id=$row['School_Id'];

	  echo '<option value="'.$Sch_Id.'">'.$Sch_Id.'</option>';
  }
	  ?>
      </select></td>
      </tr>
    
    <tr>
      <td height="24" colspan="5" align="left" bgcolor="#6AB5FF" scope="row"><a href="SearchLabSch.php" class="reset">Reset |</a>
        <input name="Search" align="middle" type="submit" value="Search" /></td>
      <td height="24" colspan="2" align="left" bgcolor="#6AB5FF" scope="row"><?php
      if(isset($_POST['Search']))
{
if(isset($_SESSION['errornotallo']))
{
echo $_SESSION['errornotallo'];
unset($_SESSION['errornotallo']);
}
}
?></td>
      </tr>
  </table></form>
   <?php
   
	   if(isset($_POST['Search']))
	   {
	  
	$Lab_Id=$_POST['Lab_Id'];
   $School_Id=$_POST['School_Id'];
	   }
	   
	   if($Lab_Id!="Select One"&&$School_Id!="Select One")
	   {
     if($_SESSION['Access_Type']=="Teacher in Charge"||$_SESSION['Access_Type']=="Teacher")
{
   $NIC_Number=$_SESSION['NIC_Number'];
   $get_Sch=mysql_query("SELECT * FROM teacher WHERE T_NIC_Number='$NIC_Number'");
   if($rowsch=mysql_fetch_array($get_Sch))
{
   $Own_School_Id=$rowsch['School_Id'];
  
   if($School_Id==$Own_School_Id)
	{$result=mysql_query("SELECT * FROM lab WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
	   $resultnet=mysql_query("SELECT * FROM network WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");

    echo '<table width="458" border="0">';
	while($row=mysql_fetch_array($result))
  { 
  if($rownet=mysql_fetch_array($resultnet))
{
	 $Availability_Of_LAN=$rownet['Availability_Of_LAN'];
   $LAN_Supplier=$rownet['LAN_Supplier'];
      	$Supplied_Date=$rownet['Supplied_Date'];
    $Speed_Of_WAN=$rownet['Speed_Of_WAN'];
    $WAN_Connection_Type=$rownet['WAN_Connection_Type'];
	$Wired_Date=$rownet['Wired_Date'];
	$Internet_Facilities=$rownet['Internet_Facilities'];
	}
  $Lab_Id=$row['Lab_Id'];
   $School_Id=$row['School_Id'];
 $Source_Of_Power=$row['Source_Of_Power'];
      	$Tp_Number=$row['Tp_Number'];
    $Account_Number=$row['Account_Number'];
    $Date_of_commencement=$row['Date_of_commencement'];   
       echo '<tr>';
        echo '<th width="200" height="25" scope="row">';
		echo "
		Source Of Power:";
		echo '</th>';
        echo '<td width="144">';
		echo "<input type='text' name='Source_Of_Power' value='$Source_Of_Power' readonly='readonly'/>";
		
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "
		Telephone Number:";
		echo '</th>';
        echo '<td>';
		echo "<input type='text' name='Source_Of_Power' value='$Tp_Number' readonly='readonly'/>";
		
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "
		Account Number:";
		echo '</th>';
        echo '<td>';
		echo "<input type='text' name='Source_Of_Power' value='$Account_Number' readonly='readonly'/>";
	
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Date of commencement :";
		echo '</th>';
       echo '<td>';
	   echo "<input type='text' name='Source_Of_Power' value='$Date_of_commencement' readonly='readonly'/>";

	   echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Availability of LAN:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Availability_Of_LAN))
		{
		echo "<input type='text' name='Availability_Of_LAN' value='$Availability_Of_LAN' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Availability_Of_LAN' readonly='readonly'/>";
		}
        echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "LAN Supplier:"; 
		echo '</th>';
        echo '<td>';
		if(isset($LAN_Supplier))
		{
		echo "<input type='text' name='LAN_Supplier' value='$LAN_Supplier' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='LAN_Supplier' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	  echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Supplied Date:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Supplied_Date))
		{
		echo "<input type='text' name='Supplied_Date' value='$Supplied_Date' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Supplied_Date' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	 
 echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Speed Of WAN:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Speed_Of_WAN))
		{
		echo "<input type='text' name='Speed_Of_WAN' value='$Speed_Of_WAN' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Speed_Of_WAN' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	  echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "WAN Connection Type:"; 
		echo '</th>';
        echo '<td>';
		if(isset($WAN_Connection_Type))
		{
		echo "<input type='text' name='WAN_Connection_Type' value='$WAN_Connection_Type' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='WAN_Connection_Type' readonly='readonly'/>";
		}
		
		echo '</td>';
      echo '</tr>';
	  
	  echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Wired Date:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Wired_Date))
		{
		echo "<input type='text' name='Wired_Date' value='$Wired_Date' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Wired_Date' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	   echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Internet_Facilities:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Internet_Facilities))
		{
		echo "<input type='text' name='Internet_Facilities' value='$Internet_Facilities' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Internet_Facilities' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	 
  }
    echo '</table>';
	}
	}
	}
	else if($_SESSION['Access_Type']=="Administrator")
{
   $result=mysql_query("SELECT * FROM lab WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
	   $resultnet=mysql_query("SELECT * FROM network WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");

    echo '<table width="458" border="0">';
	while($row=mysql_fetch_array($result))
  { 
  if($rownet=mysql_fetch_array($resultnet))
{
	 $Availability_Of_LAN=$rownet['Availability_Of_LAN'];
   $LAN_Supplier=$rownet['LAN_Supplier'];
      	$Supplied_Date=$rownet['Supplied_Date'];
    $Speed_Of_WAN=$rownet['Speed_Of_WAN'];
    $WAN_Connection_Type=$rownet['WAN_Connection_Type'];
	$Wired_Date=$rownet['Wired_Date'];
	$Internet_Facilities=$rownet['Internet_Facilities'];
	}
  $Lab_Id=$row['Lab_Id'];
   $School_Id=$row['School_Id'];
 $Source_Of_Power=$row['Source_Of_Power'];
      	$Tp_Number=$row['Tp_Number'];
    $Account_Number=$row['Account_Number'];
    $Date_of_commencement=$row['Date_of_commencement'];   
       echo '<tr>';
        echo '<th width="200" height="25" scope="row">';
		echo "
		Source Of Power:";
		echo '</th>';
        echo '<td width="144">';
		echo "<input type='text' name='Source_Of_Power' value='$Source_Of_Power' readonly='readonly'/>";
		
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "
		Telephone Number:";
		echo '</th>';
        echo '<td>';
		echo "<input type='text' name='Source_Of_Power' value='$Tp_Number' readonly='readonly'/>";
		
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "
		Account Number:";
		echo '</th>';
        echo '<td>';
		echo "<input type='text' name='Source_Of_Power' value='$Account_Number' readonly='readonly'/>";
	
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Date of commencement :";
		echo '</th>';
       echo '<td>';
	   echo "<input type='text' name='Source_Of_Power' value='$Date_of_commencement' readonly='readonly'/>";

	   echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Availability of LAN:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Availability_Of_LAN))
		{
		echo "<input type='text' name='Availability_Of_LAN' value='$Availability_Of_LAN' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Availability_Of_LAN' readonly='readonly'/>";
		}
        echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "LAN Supplier:"; 
		echo '</th>';
        echo '<td>';
		if(isset($LAN_Supplier))
		{
		echo "<input type='text' name='LAN_Supplier' value='$LAN_Supplier' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='LAN_Supplier' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	  echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Supplied Date:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Supplied_Date))
		{
		echo "<input type='text' name='Supplied_Date' value='$Supplied_Date' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Supplied_Date' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	 
 echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Speed Of WAN:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Speed_Of_WAN))
		{
		echo "<input type='text' name='Speed_Of_WAN' value='$Speed_Of_WAN' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Speed_Of_WAN' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	  echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "WAN Connection Type:"; 
		echo '</th>';
        echo '<td>';
		if(isset($WAN_Connection_Type))
		{
		echo "<input type='text' name='WAN_Connection_Type' value='$WAN_Connection_Type' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='WAN_Connection_Type' readonly='readonly'/>";
		}
		
		echo '</td>';
      echo '</tr>';
	  
	  echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Wired Date:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Wired_Date))
		{
		echo "<input type='text' name='Wired_Date' value='$Wired_Date' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Wired_Date' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	   echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Internet_Facilities:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Internet_Facilities))
		{
		echo "<input type='text' name='Internet_Facilities' value='$Internet_Facilities' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Internet_Facilities' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	 
  }
    echo '</table>';
	}
	else
	   {
	   $_SESSION['errornotallo']="Sorry you are not allowed to do this!";
	   }
	}
   ?>
 
</div>
</div>

<div class="rightmenu"> 
<?php
include_once "menu.php";
?>
 <?php
include_once "../footer.php";
?>
<?php
}
	  
	   ?>
</body>
</html>